/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CU001.java
 *
 * Created on 03/11/2012, 12:01:17
 */
package victory;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JTextField;


/**
 *
 * @author Loreley
 * 
 * 
 */
public class CU001 extends javax.swing.JPanel {
    private String apellido1;
    private boolean apellidoOK = false;
    private String nombre1;
    private boolean nombreOK = false;
    private String documento1;
    private boolean documentoOK=false;
    private String localidad1;
    private boolean localidadOK=false;

    /** Creates new form CU001 */
    public CU001() {
        initComponents();

        System.out.println("Entro al constructor de CU001");
        
        boton_cancelar.addActionListener(new ActionListener(){
            public void actionPerformed (ActionEvent e){             
                System.out.print("lalalalala 1" + boton_cancelar.getText());
        }
        });
        
        boton_confirmar.addActionListener(new ActionListener(){
                              

            public void actionPerformed (ActionEvent e){
                if( !apellidoOK && !nombreOK && !documentoOK && !localidadOK){
                System.out.print("entrooooooo");}
                else{System.out.print("te falta completar uno eeehh");
                }

            ReiniciarBooleans();   
           }
            
            

        });       
        this.setVisible(true);
       
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        label_correoElectronico = new javax.swing.JLabel();
        localidad = new javax.swing.JTextField();
        label_localidad = new javax.swing.JLabel();
        provincia = new javax.swing.JComboBox();
        label_provincia = new javax.swing.JLabel();
        documento = new javax.swing.JTextField();
        label_documento = new javax.swing.JLabel();
        cb_tipoDocumento = new javax.swing.JComboBox();
        label_tipoDocumento = new javax.swing.JLabel();
        label_titulo = new javax.swing.JLabel();
        chb_terminosCondiciones = new javax.swing.JCheckBox();
        repetirContraseña = new javax.swing.JPasswordField();
        label_repetirContraseña = new javax.swing.JLabel();
        correoElectronico = new javax.swing.JTextField();
        label_apellido = new javax.swing.JLabel();
        contraseña = new javax.swing.JPasswordField();
        apellido = new javax.swing.JTextField();
        label_contraseña = new javax.swing.JLabel();
        label_nombre = new javax.swing.JLabel();
        boton_cancelar = new javax.swing.JButton();
        nombre = new javax.swing.JTextField();
        boton_confirmar = new javax.swing.JButton();

        setAutoscrolls(true);
        setMinimumSize(new java.awt.Dimension(800, 600));
        setName("ingreseDatos"); // NOI18N
        setNextFocusableComponent(apellido);
        setPreferredSize(new java.awt.Dimension(800, 600));

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(victory.VictoryApp.class).getContext().getResourceMap(CU001.class);
        label_correoElectronico.setText(resourceMap.getString("label_correoElectronico.text")); // NOI18N
        label_correoElectronico.setName("label_correoElectronico"); // NOI18N

        localidad.setName("localidad"); // NOI18N
        localidad.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                localidadKeyReleased(evt);
            }
        });

        label_localidad.setText(resourceMap.getString("label_localidad.text")); // NOI18N
        label_localidad.setName("label_localidad"); // NOI18N

        provincia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Santa Fe", "Buenos Aires", "Entre Rios", "Cordoba", "Mendoza", "San Luis", "Santiago del Estero", "Chaco", "Corrientes", "Jujuy", "Salta", "Misiones", "Formosa", "Neuquen", "Rio Negro", "Tierra del Fuego", "Chubut", "Santa Cruz", "Rio Negro", "Catamarca", "La Rioja" }));
        provincia.setName("provincia"); // NOI18N

        label_provincia.setText(resourceMap.getString("label_provincia.text")); // NOI18N
        label_provincia.setName("label_provincia"); // NOI18N

        documento.setName("documento"); // NOI18N
        documento.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                documentoKeyReleased(evt);
            }
        });

        label_documento.setText(resourceMap.getString("label_documento.text")); // NOI18N
        label_documento.setName("label_documento"); // NOI18N

        cb_tipoDocumento.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "DNI", "LC", "LE" }));
        cb_tipoDocumento.setName("cb_tipoDocumento"); // NOI18N
        cb_tipoDocumento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_tipoDocumentoActionPerformed(evt);
            }
        });

        label_tipoDocumento.setText(resourceMap.getString("label_tipoDocumento.text")); // NOI18N
        label_tipoDocumento.setName("label_tipoDocumento"); // NOI18N

        label_titulo.setFont(resourceMap.getFont("label_titulo.font")); // NOI18N
        label_titulo.setText(resourceMap.getString("label_titulo.text")); // NOI18N
        label_titulo.setName("label_titulo"); // NOI18N

        chb_terminosCondiciones.setText(resourceMap.getString("chb_terminosCondiciones.text")); // NOI18N
        chb_terminosCondiciones.setName("chb_terminosCondiciones"); // NOI18N

        repetirContraseña.setText(resourceMap.getString("repetirContraseña.text")); // NOI18N
        repetirContraseña.setName("repetirContraseña"); // NOI18N
        repetirContraseña.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                repetirContraseñaKeyReleased(evt);
            }
        });

        label_repetirContraseña.setText(resourceMap.getString("label_repetirContraseña.text")); // NOI18N
        label_repetirContraseña.setName("label_repetirContraseña"); // NOI18N

        correoElectronico.setName("correoElectronico"); // NOI18N
        correoElectronico.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                correoElectronicoKeyReleased(evt);
            }
        });

        label_apellido.setText(resourceMap.getString("label_apellido.text")); // NOI18N
        label_apellido.setName("label_apellido"); // NOI18N

        contraseña.setText(resourceMap.getString("contraseña.text")); // NOI18N
        contraseña.setToolTipText(resourceMap.getString("contraseña.toolTipText")); // NOI18N
        contraseña.setName("contraseña"); // NOI18N
        contraseña.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                contraseñaKeyReleased(evt);
            }
        });

        apellido.setName("apellido"); // NOI18N
        apellido.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                apellidoKeyReleased(evt);
            }
        });

        label_contraseña.setText(resourceMap.getString("label_contraseña.text")); // NOI18N
        label_contraseña.setName("label_contraseña"); // NOI18N

        label_nombre.setText(resourceMap.getString("label_nombre.text")); // NOI18N
        label_nombre.setName("label_nombre"); // NOI18N

        boton_cancelar.setText(resourceMap.getString("boton_cancelar.text")); // NOI18N
        boton_cancelar.setName("boton_cancelar"); // NOI18N
        boton_cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_cancelarActionPerformed(evt);
            }
        });

        nombre.setName("nombre"); // NOI18N
        nombre.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                nombreKeyReleased(evt);
            }
        });

        boton_confirmar.setText(resourceMap.getString("boton_confirmar.text")); // NOI18N
        boton_confirmar.setName("boton_confirmar"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addComponent(label_titulo)
                .addContainerGap(597, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(boton_confirmar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(boton_cancelar))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(67, 67, 67)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGap(13, 13, 13)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(label_nombre)
                                    .addComponent(label_apellido)
                                    .addComponent(label_tipoDocumento)
                                    .addComponent(label_localidad))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(cb_tipoDocumento, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(27, 27, 27)
                                        .addComponent(label_documento)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(documento, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(apellido)
                                    .addComponent(nombre)
                                    .addComponent(localidad)))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(label_contraseña)
                                    .addComponent(label_correoElectronico)
                                    .addComponent(label_repetirContraseña)
                                    .addComponent(label_provincia))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(repetirContraseña, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(contraseña, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(chb_terminosCondiciones)
                                    .addComponent(provincia, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(correoElectronico, javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE))))))
                .addGap(332, 332, 332))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addComponent(label_titulo)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(apellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label_apellido))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label_nombre))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cb_tipoDocumento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label_tipoDocumento)
                    .addComponent(label_documento)
                    .addComponent(documento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(localidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label_localidad))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(provincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label_provincia))
                .addGap(20, 20, 20)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(correoElectronico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label_correoElectronico))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(contraseña, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label_contraseña))
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(repetirContraseña, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(label_repetirContraseña))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(chb_terminosCondiciones)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(boton_cancelar)
                    .addComponent(boton_confirmar))
                .addGap(171, 171, 171))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void boton_cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_cancelarActionPerformed
        // TODO add your handling code here:
        System.out.print(evt.getActionCommand());
        this.removeAll();
        this.repaint();
    }//GEN-LAST:event_boton_cancelarActionPerformed

    private void cb_tipoDocumentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_tipoDocumentoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cb_tipoDocumentoActionPerformed

    private void apellidoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_apellidoKeyReleased
apellido1 = this.apellido.getText();
verificar(apellido1,apellidoOK);
        // TODO add your handling code here:
    }//GEN-LAST:event_apellidoKeyReleased

    private void nombreKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nombreKeyReleased
        nombre1 = this.nombre.getText();
        verificar(nombre1,nombreOK);
    }//GEN-LAST:event_nombreKeyReleased

    private void documentoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_documentoKeyReleased
        documento1 = this.documento.getText();
for (int i = 0; i < documento1.length(); i++) { 
            if (Character.isAlphabetic(documento1.charAt(i))) { 
                //es un digito 
                documentoOK = true;
            }
        }
    }//GEN-LAST:event_documentoKeyReleased

    private void localidadKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_localidadKeyReleased
        localidad1=this.localidad.getText();
        verificar(localidad1,localidadOK); 
        
    }//GEN-LAST:event_localidadKeyReleased

    private void correoElectronicoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_correoElectronicoKeyReleased
        // TODO add your handling code here:
    }//GEN-LAST:event_correoElectronicoKeyReleased

    private void contraseñaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_contraseñaKeyReleased
        // TODO add your handling code here:
    }//GEN-LAST:event_contraseñaKeyReleased

    private void repetirContraseñaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_repetirContraseñaKeyReleased
        // TODO add your handling code here:
    }//GEN-LAST:event_repetirContraseñaKeyReleased

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField apellido;
    private javax.swing.JButton boton_cancelar;
    private javax.swing.JButton boton_confirmar;
    private javax.swing.JComboBox cb_tipoDocumento;
    private javax.swing.JCheckBox chb_terminosCondiciones;
    private javax.swing.JPasswordField contraseña;
    private javax.swing.JTextField correoElectronico;
    private javax.swing.JTextField documento;
    private javax.swing.JLabel label_apellido;
    private javax.swing.JLabel label_contraseña;
    private javax.swing.JLabel label_correoElectronico;
    private javax.swing.JLabel label_documento;
    private javax.swing.JLabel label_localidad;
    private javax.swing.JLabel label_nombre;
    private javax.swing.JLabel label_provincia;
    private javax.swing.JLabel label_repetirContraseña;
    private javax.swing.JLabel label_tipoDocumento;
    private javax.swing.JLabel label_titulo;
    private javax.swing.JTextField localidad;
    private javax.swing.JTextField nombre;
    private javax.swing.JComboBox provincia;
    private javax.swing.JPasswordField repetirContraseña;
    // End of variables declaration//GEN-END:variables

    private void ReiniciarBooleans() {
                 apellidoOK=false;
                 nombreOK=false;
                 documentoOK=false;
                 localidadOK=false;
    }
    

    private void verificar(String cadena, boolean parametro) {

for (int i = 0; i < cadena.length(); i++) { 
            if (Character.isDigit(cadena.charAt(i))) { 
                //es un digito 
                parametro = true; 
    }
}
    }
}
